Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update url.py to fit WSL path that starts with "\\wsl.local" #2577

Closed
wants to merge 1 commit into from

Conversation

95833
Copy link

@95833 95833 commented Dec 10, 2024

No description provided.

@@ -56,7 +56,8 @@ def parse_uri(uri: str) -> tuple[str, str]:
path = url2pathname(parsed.path)
if os.name == 'nt':
netloc = url2pathname(parsed.netloc)
path = path.lstrip("\\")
if path[0] == '\\':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if path[0] == '\\':
if path.startswith('\\'):

@jwortmann
Copy link
Member

Could you add a test in the tests/test_url.py file with an example, i.e. some URL that is not handled correctly at the moment but would be fixed with this pull request?

I see there is already a test for a WSL URL at

LSP/tests/test_url.py

Lines 39 to 42 in c64ac00

def test_wsl_path(self):
scheme, path = parse_uri('file://wsl%24/Ubuntu-20.04/File.php')
self.assertEqual(scheme, "file")
self.assertEqual(path, R'\\wsl$\Ubuntu-20.04\File.php')

but you could add another one after that which would be handled by the change in this pull request.

@95833
Copy link
Author

95833 commented Dec 11, 2024

Can you teach me how to use tests?

@jwortmann
Copy link
Member

Basically look at the code that I linked above. You can just copy the 3 lines and change the URL to parse (with something that currently doesn't work) and also the expected outcome. self.assertEqual(A, B) means that A must evaluate to the same as B.

@95833
Copy link
Author

95833 commented Dec 11, 2024

I don't know how to run this test.

@jwortmann
Copy link
Member

The CI check on GitHub will run it after you pushed another commit.

@95833
Copy link
Author

95833 commented Dec 11, 2024

Can't I run it locally? It's a bit annoying to have to push to GitHub every time I test the code.

@jwortmann
Copy link
Member

To manually run tests locally you need to install the UnitTesting package from package control. See https://github.com/sublimelsp/LSP/blob/main/CONTRIBUTING.md#testing

I haven't done this though, but usually you know what the expected outcome should be, so it should be fine to just push new commits until it works. The commits will be squashed into a single one when the PR gets merged anyway.

@95833
Copy link
Author

95833 commented Dec 11, 2024

Okay

@95833
Copy link
Author

95833 commented Dec 11, 2024

To provide support for WSL paths, I think it would be better to update the underlying packages related to path handling rather than changing the program logic; the issue seems to have become somewhat complex. I think the best solution would be to create a branch that supports WSL paths. So this PR will be closed.

@95833 95833 closed this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants